class base::puppetconf  inherits base {
  augeas{"runinterval" :
   context => "/files/etc/puppetlabs/puppet/puppet.conf/agent/",
   changes => "set runinterval $puppetinterval",
   notify  => Exec['refreshpuppet']
  }

  augeas{"configtimeout" :
   context => "/files/etc/puppetlabs/puppet/puppet.conf/agent/",
   changes => "rm configtimeout",
   notify  => Exec['refreshpuppet']
  }

  augeas{"splay" :
   context => "/files/etc/puppetlabs/puppet/puppet.conf/agent/",
   changes => "set splay true",
   notify  => Exec['refreshpuppet']
  }

  augeas{"splaylimit" :
   context => "/files/etc/puppetlabs/puppet/puppet.conf/agent/",
   changes => "set splaylimit $puppetinterval",
   notify  => Exec['refreshpuppet']
  }

  augeas{"stringify_facts" :
   context => "/files/etc/puppetlabs/puppet/puppet.conf/agent/",
   changes => "set stringify_facts false",
   notify  => Exec['refreshpuppet']
  }

  augeas{"number_of_facts_soft_limit" :
   context => "/files/etc/puppetlabs/puppet/puppet.conf/agent/",
   changes => "set number_of_facts_soft_limit 90000",
   notify  => Exec['refreshpuppet']
  }
  augeas{"top_level_facts_soft_limit":
   context => "/files/etc/puppetlabs/puppet/puppet.conf/agent/",
   changes => "set ttop_level_facts_soft_limit 1000",
   notify  => Exec['refreshpuppet']
  }


  exec {'refreshpuppet':
    command      => "/sbin/service puppet reload",
    refreshonly  => true
  }
  cron { 'check_puppet':
    command => '/root/check_puppet.sh 2>& 1 | tee -a /var/log/check_puppet.log',
    user    => 'root',
    minute  => '*/15',
    hour    =>  '*'
  }

  cron { 'restart_puppet':
    command => '/root/restart_puppet.sh 2>& 1 | tee -a /var/log/check_puppet.log',
    user    => 'root',
    minute  => '50',
    hour    => '17'
  }
  file { "/root/restart_puppet.sh":
     ensure   => file,
     owner    => 0,
     group    => 0,
     mode     => '0755',
     source   => "puppet:///modules/${module_name}/restart_puppet.sh",
  }
  if $facts['os']['release']['major'] <= '7' {
    service { "NetworkManager":
      ensure      => 'stopped',
      enable      => false,
      hasstatus   => true,
      hasrestart  => true,
    }
    file { "/root/check_puppet.sh":
       ensure   => file,
       owner    => 0,
       group    => 0,
       mode     => '0755',
       source   => "puppet:///modules/${module_name}/check_puppet.sh",
    }
  }
  else {
    file { "/root/check_puppet.sh":
       ensure   => file,
       owner    => 0,
       group    => 0,
       mode     => '0755',
       source   => "puppet:///modules/${module_name}/check_puppet_8.sh",
    }
  }

  # This will overwrite all remote site file of ca  

  #file { '/etc/puppetlabs/puppet/ssl/certs/ca.pem': 
  #  source => "puppet:///modules/${module_name}/ca_crt.pem", 
  #  owner => 'root', 
  #  group => 'root', 
  #  #require => Package['puppet'],
  #}
}
